<% messages_id ||= active_scaffold_messages_id %>
<% if successful? %>
  <% if render_parent? %>
    <% if render_parent_action == :row %>
      <% current_id = controller_id(params[:eid] || params[:parent_sti]) -%>
      ActiveScaffold.delete_record_row('<%= element_row_id(controller_id: current_id, action: 'list', id: params[:id]) %>', '<%= url_for params_for(render_parent_options.merge(id: nil, page: [active_scaffold_config.list.user.page.to_i - 1, 1].max)) %>');
      <% messages_id = active_scaffold_messages_id(controller_id: current_id) %>
      <%= render 'update_calculations', calculations_id: active_scaffold_calculations_id(controller_id: current_id) %>
    <% elsif render_parent_action == :index %>
      <% if controller.respond_to?(:render_component_into_view, true) %>
        <%= escape_javascript(controller.send(:render_component_into_view, render_parent_options)) %>
      <% else %>
        ActiveScaffold.reload('<%= url_for render_parent_options %>');
      <% end %>
    <% end %>
  <% elsif active_scaffold_config.delete.refresh_list %>
    <%= render 'refresh_list', no_history: true %>
  <% else %>
    <%
      if active_scaffold_config.actions.exclude?(:list) || active_scaffold_config.list.pagination
        url = main_path_to_return
        url[:page] = [active_scaffold_config.list.user.page.to_i - 1, 1].max if url.is_a?(Hash) && active_scaffold_config.actions.include?(:list)
        url = url_for(url)
      end
    %>
    ActiveScaffold.delete_record_row('<%= element_row_id(action: 'list', id: params[:id]) %>', '<%= url %>');
    <%= render 'update_calculations' %>
  <% end %>
<% else %>
  <%
    if @record.errors.present?
      object_name = "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}"
      flash[:error] = active_scaffold_error_messages_for(@record, object_name: object_name, header_message: '', message: object_name, container_tag: nil, list_type: :br)
    end
  %>
<% end %>
<%= render 'update_messages', messages_id: messages_id %>
